
#ifndef _MEMBER_BTERRAIN_H_
#define _MEMBER_BTERRAIN_H_

#include <BQuadTree>
#include <BTerrain>

#define terrain_member(terrain)		((member_BTerrain*)((BTerrain*)terrain)->_ptr)

namespace BWE
{
	typedef BQuadTree<BIndexArray>				QuadTree;
	typedef BQuadTree<BIndexArray>::Item		QuadTreeItem;
	typedef BQuadTree<BIndexArray>::ItemArray	QuadTreeItemArray;

	class member_BTerrain : public BObject
	{
		friend class BTerrain;
	public:
		member_BTerrain(BTerrain* terrain);
		~member_BTerrain();

		bool rebuild();

		void slotFreshQuadTree();

		BTerrain*				boss;
		Align					align;
		BReal					width;
		BReal					height;
		BReal					skirtHeight;
		BSpace					localSpace;
		BRealTable				elevation;
		bool					dirtyArea;
		bool					dirtyZone;
		bool					dirtySkirt;
		BHolder<BVectorArray>		vertices;
		BHolder<BVectorArray>		normals;
		BHolder<BColorArray>		colors;
		BHolder<BCoordArray>		coords;
		BHolder<BIndexArray>		indices;
		BHolder<QuadTree>			quadTree;
	};
}

#endif